/*
 * Home.java
 *
 * Created on January 29, 2007, 11:11 PM
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */
package ge.info.pages;

//import ge.info.domain.DbExecutor;
import ge.info.domain.Discover;
import ge.ktapestry.pages.BasePageExt;
import org.apache.tapestry.IRequestCycle;



//import org.apache.tapestry.annotations.InjectState;
import org.apache.tapestry.annotations.Persist;
import org.apache.tapestry.event.PageBeginRenderListener;
import org.apache.tapestry.event.PageEvent;

public abstract class DiscoverPage extends BasePageExt implements PageBeginRenderListener
{

    public abstract String getErrorString();

    public abstract void setErrorString(String errString);

    @Persist
    public abstract Discover getDiscover();

    public abstract void setDiscover(Discover discover);

    public abstract String getDtxt();

    public abstract void setDtxt(String dtxt);

//    public abstract String getPhone();
//
//    public abstract void setPhone(String s);
//
//    public abstract int getDtid();
//
//    public abstract void setDtid(int i);
//
//    public abstract String getDtxt();
//
//    public abstract void setDtxt(String s);
//
//    public abstract String getContactphone();
//
//    public abstract void setContactphone(String s);
    public final static Integer SMS = new Integer(1);
    public final static Integer DISC = new Integer(2);
    public final static Integer RES = new Integer(3);
    public final static Integer TRANS = new Integer(5);
    public void pageBeginRender(PageEvent event)
    {
        if (!event.getRequestCycle().isRewinding())
        {
            Discover discover = new Discover();
            discover.setCallid(getSession().getSessionID());
            String p = null;
            if (getSession().getPhone() != null)
            {
                p = new String(getSession().getPhone());
                discover.setPhone(p);

            }

            String t = null;
            if (getDtxt() != null)
            {
                t = new String(getDtxt());

                discover.setDtxt(t);
            }

            discover.setDtid(DISC);

             if (getDtxt() != null)
            {
                t = new String(getDtxt());

                discover.setDtxt(t);
                discover.setDtid(RES);
            }

            setDiscover(discover);
        }
    }
    // @InjectState("user")
    // public abstract User getUser();

    //public abstract void setUser(User User);
    public void formSubmit(IRequestCycle cycle)
    {
        Discover d = getDiscover();
        getDbExecutor().insdiscovery(d, getSession());

    }
}
